﻿using UnityEngine;

public class ConfigData : ScriptableObject
{
    // --------------------------------------------------------------------------------------------
    // key & iv
    [HideInInspector]
    public byte[] Key;
    [HideInInspector]
    public byte[] IV;

    // --------------------------------------------------------------------------------------------
    // 项目名
    public string ProjectName = "unityFrame";

    // 游戏名
    public string GameName
    {
        get
        {
            switch (Application.systemLanguage)
            {
                default:                    // 其它显示英语
                    return "unityFrame";
            }
        }
    }

    // 版本号
    public const string DEFAULT_VERSION = "9.99.999";
    public string Version = DEFAULT_VERSION;

    public string BundleId = "com.onemt.hrm";
    private string LangForIOS = "";
    // 语言
    public string Language
    {
        get
        {
#if !UNITY_EDITOR && UNITY_IOS
			if (string.IsNullOrEmpty (LangForIOS)) {
				string languages = NativeAgent.GetLanguages ();
				SimpleJSON.JSONArray json = SimpleJSON.JSONNode.Parse (languages) as SimpleJSON.JSONArray;
				for (int i = 0; i < json.Count; ++i) {
					string language = json [i].Value;

					if (language.StartsWith ("en")) {
						LangForIOS = "en";
						break;
					}else if (language.StartsWith ("tr")) {
						LangForIOS = "tr";
						break;
					} else if (language.StartsWith ("ar")) {
						LangForIOS = "arab";
						break;
					}else{
						LangForIOS = "en";
					}
				}
			}

			if (!string.IsNullOrEmpty (LangForIOS)) {
				return LangForIOS;
			}
#endif

            switch (Application.systemLanguage)
            {
                case SystemLanguage.Turkish:
                    return "tr";
                case SystemLanguage.Arabic:
                    return "arab";
                default:
                    // 其它显示英语
                    return "en";
            }
        }
    }

    // 使用Luajit
    public bool UseLuaJit = true;

    // 开启更新
    public bool CheckUpdate = false;

    // 开启分包(Android)
    public bool ResourceSplit = false;

    // 发布类型
    public ReleaseType Release = ReleaseType.TEST;

    // 使用TexturePacker大图(废弃,暂时保留,以免哪天又想用)
    [HideInInspector]
    public bool UseTexturePacker = true;

    public bool IsDeveloper
    {
        get
        {
            return Release == ReleaseType.TEST;
        }
    }

    // --------------------------------------------------------------------------------------------
    // URL(用于更新)
    string ms_UpdateURLRelease = "https://{0}version.menaapp.net/";         // 正式包版本文件
    string ms_UpdateURLReleaseData = "https://{0}update.menaapp.net/";      // 正式包资源
    string ms_UpdateURLTest = "http://mactest.onemt.co:88/{0}/";            // 测试包

    [HideInInspector]
    public string UpdateName = "updatePackage";             // 更新目录名
    [HideInInspector]
    public string HDResName = "hd_res";                 // 高清资源目录名

    // 版本文件路径
    public string UpdateURL
    {
        get
        {
            switch (Release)
            {
                case ReleaseType.RELEASE:
                    return string.Format(ms_UpdateURLRelease, ProjectName);
                default:
                    return string.Format(ms_UpdateURLTest, ProjectName);
            }
        }
    }

    // 资源文件路径
    public string UpdateDataURL
    {
        get
        {
            switch (Release)
            {
                case ReleaseType.RELEASE:
                    return string.Format(ms_UpdateURLReleaseData, ProjectName);
                default:
                    return string.Format(ms_UpdateURLTest, ProjectName);
            }
        }
    }

    // --------------------------------------------------------------------------------------------
    // 打包编码(每次打包时生成,区分每一个包,暂时用打包时间)
    public string PackageCode = "";

    // 最小需要空间(默认400MB)
    public long MinNeedDiskSize = 419430400;

    public string ErrorRebotToken = "24f208385a65980d627ca4c707b1884473313e1d4c59a12dfe880fb970b91605";
}
